<%@ page contentType="text/html;charset=utf-8" language="java"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@include file="./common/base.jsp" %>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>会员注册_约导游</title>
<!--css-->
<link rel="stylesheet" type="text/css" href="css/wutongstyle.css">
<script src="js/nTab.js" type="text/javascript"></script>
<link rel="stylesheet" type="text/css" href="city/citySelector.css">
<script src="city/citySelector.js" type="text/javascript"></script>

</head>

<body>
<!--head begin-->
<%@ include  file="./common/header.jsp"%>
<!--nav end--> 
<!--content begin-->
<div class="wt_content">
  <dl class="yuedaoyou">
    <dt><span>您的位置：<a href="index.html">约导游</a> &gt; <a href="join.jsp">注册</a></span>新用户注册</dt>
    <dd>
      <div class="zhuce clearfix">
        <div class="zhuce_left">
          <ul id="myTab" class="clearfix">
            <li onclick="nTabs(this,0);" class="active">我是导游</li>
            <li onclick="nTabs(this,1);" class="normal">我是旅行社</li>
            <li onclick="nTabs(this,2);" class="normal">我是网友</li>
          </ul>
          <form id="myTab_Content0" style="display: block; " class="myTab_box">
            <ul>
              <li><span>真实姓名：</span>
                <input type="text" id="nameId" name="name" xvalue="" placeholder="" >
              </li>
              <li><span>身份证号：</span>
                <input type="text" id="idnumId" name="idnum" value="" placeholder="" >
              </li>
              <li><span>导游证号：</span>
                <input type="text" id="guidenumId" name="guidenum" value="" placeholder="学生导游可以不用填写" >
              </li>
              <li><span>所在城市：</span>
                <input type="text" id="szCityId" name="szCity" value="" class="cityinput" placeholder="">
              </li>
               <!--<li><span>导游证号：</span>
                <input type="text" id="guidenumId" value="" placeholder="请准确填写手机号码方便联系">
              </li>-->
              <li><span>手机号码：</span>
                <input type="text" id="phoneId" name="phone" value="" placeholder="请准确填写手机号码方便联系">
              </li>
              <!--  <li><span>电子信箱：</span>
                <input type="text" id="emailId" value="" placeholder="请准确填写手机号码方便联系">
              </li>-->
              <li><span>用户账号：</span>
                <input type="text" id="userNameId" name="userName" value="" placeholder="请准确填写用户名，登陆使用">
              </li>
              <li><span>密　　码：</span>
                <input type="password" name="passwordN" id="passwordId" value="">
              </li>
              <li><span>确认密码：</span>
                <input type="password" name="confirmPass" id="confirm_passId" value="">
              </li>
              <li>点击注册即表示同意约导游网站用户协议</li>
              <li>
                <button type="button" value="确认注册导游身份" onclick="register(2);">确认注册导游身份</button>
              </li>
            </ul>
          </form>
          <form id="myTab_Content1" style="display: none; " class="myTab_box">
            <ul>
             
              <li><span>旅行社名：</span>
                <input type="text" id="name2Id" name="name2" value="" placeholder="请准确填写旅行社名称">
              </li>
              <li><span>营业执照：</span>
                <input type="text" id="buslicnumId" name="buslicnum" value="" placeholder="">
              </li>
              <li><span>许可证号：</span>
                <input type="text" id="licnumId" name="licnum" value="" placeholder="">
              </li>
              <li><span>法　　人：</span>
                <input type="text" id="contact2Id" name="contact2" value="" placeholder="">
              </li>
              <li><span>联系电话：</span>
                <input type="text" id="phone2Id" name="phone2" value="" placeholder="请准确填写手机号码方便联系">
              </li>
              <li><span>所在城市：</span>
                <input type="text" id="szCity2Id" name="szCity2" value="" class="cityinput" placeholder="">
              </li>
              <li><span>用户账号：</span>
                <input type="text" id="userName2Id" name="userName2" value="" placeholder="请准确填写用户名，登陆使用">
              </li>
              <li><span>密　　码：</span>
                <input type="password" id="pass2Id" name="pass2" value="">
              </li>
              <li><span>确认密码：</span>
                <input type="password" name="confirmPass2" id="confirmPass2Id" value="">
              </li>
              <li>点击注册即表示同意约导游网站用户协议</li>
              <li>
                <button type="button" value="确认注册旅行社身份" onclick="register(0);">确认注册旅行社身份</button>
              </li>
            </ul>
          </form>
          <form id="myTab_Content2" style="display: none; " class="myTab_box">
            <ul>
              <li><span>姓　　名：</span>
                <input type="text" id="name3Id" name="name3" value="" placeholder="请准确填写姓名">
              </li>
              <li><span>身份证号：</span>
                <input type="text" id="idnum3Id" name="idnum3" value="">
              </li>
              <li><span>手机号码：</span>
                <input type="text" id="phone3Id" name="phone3" value="" placeholder="请准确填写手机号码方便联系">
              </li>
              <li><span>电子信箱：</span>
                <input type="text" id="email3Id" name="email3" value="" placeholder="常用电子信箱便于联系">
              </li>
              <li><span>用户账号：</span>
                <input type="text" id="userName3Id" name="userName3" value="">
              </li>
              <li><span>密　　码：</span>
                <input type="password" id="pass3Id" name="pass3" value="">
              </li>
              <li><span>确认密码：</span>
                <input type="password" id="confirmPass3Id" name="confirmPass3" value="">
              </li>
              <li>点击注册即表示同意约导游网站用户协议</li>
              <li>
                <button type="button" value="确认注册网友身份" onclick="register(1)">确认注册网友身份</button>
              </li>
            </ul>
          </div>
        </form>
        <div class="zhuce_right">
          <ul>
            <li class="no1">已有约导游网站账号？</li>
            <li class="no2"><a href="login.jsp">立即登录</a></li>
          </ul>
          <div class="zhuce_fuwu">
            <p>成为约导游会员享受更多会员服务</p>
            <ul>
              <li>在线定制旅游产品得积分奖励</li>
              <li>会员专享优惠产品及代金券</li>
              <li>订单点评得积分奖励</li>
              <li>扫一扫关注我们100元好礼相送</li>
            </ul>
          </div>
          <div class="zhuce_fuwu">
            <p>通过其他账号登陆本站</p>
          </div>
        </div>
      </div>
    </dd>
  </dl>
</div>
<!--content end--> 
<div class="tipc" style="display:none;" id="showWanShanId"><a href="dylogin_3.jsp" id="toUserDetailId">请先完善注册资料</a>
</div>
<!--footer begin-->
<%@ include  file="./common/footer.jsp"%>
<!--footer end-->
</body>
<script type="text/javascript">
/*表单验证*/
/* $(function() {
	$("#myTab_Content0").validate({
		rules:{
			nameId:{
				required:true,
				minlength: 2,
				maxlength:12
			}
			
		},
		messages:{
			nameId:"Name不能为空"
		}
	})
}); */
function guideValidate()  
{  
    return $('#myTab_Content0').validate({  
        rules:{  
        	name:'required', 
        	idnum:'required', 
        	szCity:'required', 
        	phone:'required', 
        	userName:'required', 
        	passwordN:'required', 
        	confirmPass:'required'
        	
            },  
        messages:{  
        	name:'&nbsp;&nbsp;请输入真实姓名',
        	idnum:'&nbsp;&nbsp;请输入身份证号码',  
        	szCity:'&nbsp;&nbsp;请选择所在城市',  
        	phone:'&nbsp;&nbsp;请输入联系方式',  
        	userName:'&nbsp;&nbsp;请输入登录用户名',  
        	passwordN:'&nbsp;&nbsp;请输入登陆密码',  
        	confirmPass:'&nbsp;&nbsp;请重新舒输入密码'
        	
            },  
    });  
} 

function lxsValidate() {
	return $('#myTab_Content1').validate({  
        rules:{  
        	name2:'required', 
        	buslicnum:'required', 
        	licnum:'required', 
        	contact2:'required', 
        	phone2:'required', 
        	szCity2:'required', 
        	userName2:'required',
        	pass2:'required', 
        	confirmPass2:'required'
        	
            },  
        messages:{  
        	name2:'&nbsp;&nbsp;请填写旅行社名',
        	buslicnum:'&nbsp;&nbsp;请填写资格证号',  
        	licnum:'&nbsp;&nbsp;请填写许可证号',  
        	contact2:'&nbsp;&nbsp;请填写法人',  
        	phone2:'&nbsp;&nbsp;请填写手机号',  
        	szCity2:'&nbsp;&nbsp;请选择所在城市',  
        	userName2:'&nbsp;&nbsp;请填写系统登陆用户名',
        	pass2:'&nbsp;&nbsp;请输入密码', 
        	confirmPass2:'&nbsp;&nbsp;请重新输入密码'
        	
            },  
    });  
}


function personalValidate() {
	return $('#myTab_Content2').validate({  
        rules:{  
        	name3:'required', 
        	idnum3:'required', 
        	phone3:'required', 
        	email3:{
        		required: true,
        	    email: true
        	},
        	userName3:'required',
        	pass3:'required', 
        	confirmPass3:'required'
        	
            },  
        messages:{  
        	name3:'&nbsp;&nbsp;请填写旅行社名',
        	idnum3:'&nbsp;&nbsp;请输入身份证号码',  
        	phone3:'&nbsp;&nbsp;请填写手机号', 
        	email3:{
        		required: '&nbsp;&nbsp;请输入邮箱',
        	    email: '&nbsp;&nbsp;请输入正确邮箱格式,例:xxx@xxx.com'
        	},
        	userName3:'&nbsp;&nbsp;请填写系统登陆用户名',
        	pass3:'&nbsp;&nbsp;请输入密码', 
        	confirmPass3:'&nbsp;&nbsp;请重新输入密码'
        	
            },  
    });  
}
  

function register(userType) {
	
		var objp;
		if(userType==0){//旅行社
			if(lxsValidate().form()){
				var name = $("#name2Id").val();
				var buslicnum = $("#buslicnumId").val();
				var licnum = $("#licnumId").val();
				var phone = $("#phone2Id").val();
				var contact = $("#contact2Id").val();
				var city = $("#szCity2Id").val();
				var userName = $("#userName2Id").val();
				var password = $("#pass2Id").val();
				var confirm_pass = $("#confirmPass2Id").val();
				objp= "{\"userType\":"+userType+","+
		        "\"name\":\""+name+"\","+
		        "\"buslicnum\":\""+buslicnum+"\","+
		        "\"licnum\":\""+licnum+"\","+
		        "\"phone\":\""+phone+"\","+
		        "\"contact\":\""+contact+"\","+
		        "\"city\":\""+city+"\","+
		        "\"userName\":\""+userName+"\","+
		        "\"password\":\""+password+"\""+
		        "}";
			}else{
				return;
			}
		}else if(userType==1){//个人
			if(personalValidate().form()){
			var name = $("#name3Id").val();
			var idnum = $("#idnum3Id").val();
			var phone = $("#phone3Id").val();
			var email = $("#email3Id").val();
			var userName = $("#userName3Id").val();
			var password = $("#pass3Id").val();
			var confirm_pass = $("#confirmPass3Id").val();
			objp= "{\"userType\":"+userType+","+
	        "\"name\":\""+name+"\","+
	        "\"idnum\":\""+idnum+"\","+
	        "\"phone\":\""+phone+"\","+
	        "\"email\":\""+email+"\","+
	        "\"userName\":\""+userName+"\","+
	        "\"password\":\""+password+"\""+
	        "}";
			}else{
				return ;
			}
		}else{//导游
			if(guideValidate().form()){
				var name = $("#nameId").val();
				var idnum = $("#idnumId").val();
				//var guidenum= $("#guidenumId").val();
				var city = $("#szCityId").val();
				var guidenum = $("#guidenumId").val();
				var phone = $("#phoneId").val();
				//var email = $("#emailId").val();
				var userName = $("#userNameId").val();
				var password = $("#passwordId").val();
				var confirm_pass = $("#confirm_passId").val();
				objp= "{\"userType\":"+userType+","+
					         "\"name\":\""+name+"\","+
					         "\"idnum\":\""+idnum+"\","+
					         "\"city\":\""+city+"\","+
					         "\"phone\":\""+phone+"\","+
					         "\"guidenum\":\""+guidenum+"\","+
					         "\"userName\":\""+userName+"\","+
					         "\"password\":\""+password+"\""+
					         "}";
			}else{
				return;
			}
		}

		   $.ajax({
				  url: '${path}/core/register',
				  type: 'POST',
				  timeout: 30000,
				  cache : false,
			      data :objp,
			      async: false,
			      dataType:"json",      
		          contentType:"application/json",   
			     // contentType: "application/json; charset=utf-8",
				  success:function(msg){
					  alert("注册ok");//跳转到一个流程页面，邮箱等等要必填，审批通过我们会邮件通知，登陆
					  document.getElementById("showWanShanId").style.display="block";
					  if(userType==0||userType==1){
						 // window.location.href='${path}/lxslogin_5.jsp'; 
						  $("#toUserDetailId").attr("href","lxslogin_5.jsp");
					  }else{
						  $("#toUserDetailId").attr("href","dylogin_3.jsp");
						  //window.location.href='${path}/dylogin_3.jsp'; 
					  }
				  },
				   failure:function(msg){
					   alert(eval('('+msg.responseText+')').error_text);
				   		
				   },
				   error:function(msg){
					   alert(eval('('+msg.responseText+')').error_text); 
				   }
			});
	
	
}
new Vcity.CitySelector({input:'szCityId'});
new Vcity.CitySelector({input:'szCity2Id'});
</script>
</html>
